This is what happens when you use Windows so you're reliable for projectors.
Okay so today I want to talk about Crow. What is Crow?
Crow is a set of libraries for the Roku language for building effectively distributed systems
but it turns out most of the distributed systems people want to build are either web APIs or web applications.
So probably almost all of its usages for that, but it also speaks things like LDAP and so forth as well.
So
there is kind of a little bit like Git. You have plumbing and you have porcelain and I'm gonna really talk about porcelain mostly today.
But at the very base of it all is something called Cro-Core,
which is a way of composing systems that process network requests and
so forth out of a set of small components. For example,
HTTP pipeline is a request parser and then something that's the application and then something that makes a HTTP response.
On top of Cro-Core, we have CroTLS, which is for providing transport layer security using the OpenSSL.
On top of that, we finally reached something that you might want to use.
This actually has a bunch of plumbing components for HTTP
and then the bits in white are the the user space stuff if you like and
there's a HTTP client and then there's a HTTP server and the router and that's largely what I'll talk about today.
So this module is actually pretty useful in its own right if what you're building is a
HTTP API
or a
some kind of single page application where what you actually have behind it is
really just serving a JavaScript application and then a load of routes that do JSON stuff.
On top of that there is Cro-WebSocket, which is WebSockets for
interactivity stuff and
again, there's plumbing and then there's a client and then there's a router plug-in so you can very easily receive a request and then say
okay, let's upgrade this to a WebSocket and
finally on top
there's Cro-WebApp, which is actually a web framework built on top of the whole thing for when you're doing more
server-side applications and
for a while we were like no, we're not building web framework. We're not building web framework and then finally, yeah, okay
we are building a web framework.
So, fine, okay. So we'll talk about these three bits today and
what is the router? What is this all about? So it's the thing that takes an incoming HTTP request and
says okay, this looks like a HTTP request.
What should we do with it? And it decides what bit of logic is going to handle that and
it'll potentially apply a lot of rules before that to decide it.
Many things plug into the router as well. So things like WebSocket support, things like templating and web form handling and
OpenAPI are all built atop of this.
So once you're familiar with the basics of it, then you're ready to move on and add all of these extras
according to what you need.
So how do we get set up with a core application?
Because we need one of those before we can play with the router.
We can write a little bit of code if we don't like using any kind of tooling. So we use a couple of
modules. We then
see our first example of the root block there and
this
root here is where we define the different roots that is mappings of incoming requests to code to handle them.
And in this case, we're just handling the the request to the the base URL, just a slash,
and just saying return a text plane response that says hello world. Now in crow, a web application is
anything that
transforms a HTTP request into a HTTP response.
Presenters
Jonathan Worthington
Zugänglich über
Offener Zugang
Dauer
00:48:22 Min
Aufnahmedatum
2020-03-04
Hochgeladen am
2020-03-04 21:11:37
Sprache
en-US
Cro is a set of libraries and tools for building distributed systems in Raku. It is most commonly used for building HTTP services and web applications.
The Cro HTTP router provides a means to maps incoming requests into code to handle them and produce a response. This talk explores some of the vast range of functionality provided by the router and various plugins to it, including:
* Matching on path segments
* Serving static content
* Serving dynamic responses
* Rendering a template
* Obtaining values from the query string, cookies, and headers
* Handling request bodies
* Producing appropriate HTTP responses
* Composing more complex applications from multiple pieces
* Web sockets
* Sessions, authentication, and authorization
* Various ways of adding middleware
* Custom body parsers and serializers